<?php
/**
 * Created by PhpStorm.
 * User: shiyang
 * Date: 2018/12/18
 * Time: 22:03
 */

namespace App\Models\Traits;


use Auth;
use Carbon\Carbon;

trait LastActivedAtHelper
{
    /**
     * 记录登录用户的最后活动时间
     */
    public function recordLastActivedAt()
    {
        // 当前时间，如：2018-12-11 12:35:14
        $now = Carbon::now()->toDateTimeString();

        $user = Auth::user();
        $user->last_actived_at = $now;
        $user->save();
    }
}
